import unittest
from HTMLTestRunner import HTMLTestRunner

class TestMyTestCase(unittest.TestCase):
    def test_addition(self):
        self.assertEqual(1 + 1, 2)

    def test_subtraction(self):
        self.assertEqual(2 - 1, 1)

if __name__ == '__main__':
    # 创建测试套件
    suite = unittest.TestSuite()
    suite.addTest(TestMyTestCase('test_addition'))
    suite.addTest(TestMyTestCase('test_subtraction'))

    # 打开报告文件
    with open('test_report.html', 'wb') as report:
        # 创建 HTMLTestRunner 实例
        runner = HTMLTestRunner(stream=report, title='测试报告', description='测试用例执行情况')
        # 运行测试套件
        runner.run(suite)
